<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
<div id="app">

    <div v-for="user in userList">
        {{user.name}}------{{user.age}}
    </div>

</div>
<script src="vue.min.js"></script>
<script src="axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            userList: []
        },
        created() {
            //在页面渲染之前执行
            console.log('created....')
            this.getUserList()
        },
        methods:{
            //在页面渲染之后执行
            getUserList()
            {
                axios.get("data.json")
                    //请求成功执行then方法
                    //response就是请求之后返回数据
                    //console.log(response)
                    //通过response获取具体数据，赋值给定义空数组
                    .then(response =>{
                        console.log("response is "+response)
                        this.userList = response.data.data.items
                        console.log(this.userList)
                    })
                    .catch(error =>{

                    })
            }
        }
    })
</script>
</body>

</html>